<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <title>Edit Clique</title>
</head>
<body>
<div class="nav">
    <span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}">Home</a></span>
    <span class="menuButton"><g:link class="list" action="list">Clique List</g:link></span>
    <span class="menuButton"><g:link class="create" action="create">New Clique</g:link></span>
</div>
<div class="body">
    <h1>Edit Clique</h1>
    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${clique}">
        <div class="errors">
            <g:renderErrors bean="${clique}" as="list"/>
        </div>
    </g:hasErrors>
    <g:form method="post">
        <input type="hidden" name="id" value="${clique?.id}"/>
        <div class="dialog">
            <table>
                <tbody>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="members">Members:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: clique, field: 'members', 'errors')}">

                            <ul>
                                <g:each var="m" in="${clique?.members?}">
                                    <li><g:link controller="person" action="show" id="${m.id}">${m}</g:link></li>
                                </g:each>
                            </ul>
                            <g:select name="person.id" from="${Person.list()}" optionKey="id"  noSelection="['':'Add a Member']"/>
                            <g:link controller="person" params="["clique.id":clique?.id]" action="create">Add Person</g:link>

                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="name">Name:</label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: clique, field: 'name', 'errors')}">
                            <input type="text" id="name" name="name" value="${fieldValue(bean: clique, field: 'name')}"/>
                        </td>
                    </tr>

                </tbody>
            </table>
        </div>
        <div class="buttons">
            <span class="button"><g:actionSubmit class="save" value="Update"/></span>
            <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete"/></span>
        </div>
    </g:form>
</div>
</body>
</html>
